package com.gitee.demo.constants;

import java.util.HashMap;
import java.util.Map;

/**
 * @author haixiong.chen
 * @date 2018/12/20 21:12
 */
public enum HttpHeaderContentTypeEnum {

    JSON("1", "application/json"),
    X_WWW_FORM("2", "application/x-www-form-urlencoded"),
    FORM_DATA("3", "multipart/form-data"),
    ;

    final static Map<String, HttpHeaderContentTypeEnum> cache = new HashMap<>(values().length);

    static {
        for (HttpHeaderContentTypeEnum e : values()) {
            cache.put(e.key, e);
        }
    }

    private String key;
    private String desc;

    HttpHeaderContentTypeEnum(String key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public static HttpHeaderContentTypeEnum convert(String key) {
        HttpHeaderContentTypeEnum type = cache.get(key);
        return type;
    }

    public String getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }
}
